<?php
/**
 * Created by PhpStorm.
 * User: Frings
 * Date: 2017/4/27
 * Time: 10:14
 */

use app\models\RoleExt;
use yii\helpers\Url;

$web = Url::base();
$role_list = RoleExt::getRoleList();
?>
<script type="text/javascript">
    $(function () {
    });

</script>

<div class="form-horizontal" id="manager_edit_form">
    <input type="hidden" id="id" name="id" class="form-control"
           value="<?= isset($item['id']) != null ? $item['id'] : '' ?>">

    <div class="form-group" style=" margin-top: 5px">
        <label class="control-label col-lg-2" for="name"><span class="font-color-attention">*</span>名称：</label>
        <div class="col-lg-10">
            <input type="text" id="name" name="name" class="form-control"
                   value="<?= $item != null ? $item['name'] : '' ?>">
        </div>
    </div>

    <div class="form-group" style=" margin-top: 5px">
        <label class="control-label col-lg-2" for="account"><span class="font-color-attention">*</span>账号：</label>
        <div class="col-lg-10">
            <input type="text" id="account" name="account" class="form-control"
                   value="<?= $item != null ? $item['account'] : '' ?>" <?= $item != null ? "disabled" : '' ?> >
        </div>
    </div>

    <?php
    if (!isset($item)) {
        ?>
        <div class="form-group" style=" margin-top: 5px">
            <label class="control-label col-lg-2" for="password"><span class="font-color-attention">*</span>密码：</label>
            <div class="col-lg-10">
                <input type="password" id="password" name="password" class="form-control"
                       value="">
            </div>
        </div>
        <?php
    }
    ?>


    <div class="form-group" style=" margin-top: 5px">
        <label class="control-label col-lg-2" for="phone"><span class="font-color-attention">*</span>电话号码：</label>
        <div class="col-lg-10">
            <input type="text" id="phone" name="phone" class="form-control"
                   value="<?= $item != null ? $item['phone'] : '' ?>">
        </div>
    </div>
    <div class="form-group" style=" margin-top: 5px">
        <label class="control-label col-lg-2" for="remark">备注：</label>
        <div class="col-lg-10">
            <input type="text" id="remark" name="remark" class="form-control"
                   value="<?= $item != null ? $item['remark'] : '' ?>">
        </div>
    </div>

    <div class="form-group" style=" margin-top: 5px">
        <label class="control-label col-lg-2" for="is_enabled">启用：</label>
        <div class="col-lg-10">
            <div class="checkbox-switch-wrapper">
                <input class="checkbox-switch" type="checkbox" id="is_enabled" name="is_enabled"
                    <?php
                    if (isset($item['is_enabled']) && $item['is_enabled'] == 1) {
                        echo 'checked="checked"';
                    } else if (!isset($item['is_enabled'])) {
                        echo 'checked="checked"';
                    }
                    ?>
                >
                <div class="checkbox-switch-circle"></div>
            </div>
        </div>
    </div>
    <div class="form-group" style="margin-top: 5px">
        <label for="role_id" class="control-label col-lg-2">角色(多选)：</label>
        <div class="col-lg-10">
            <label for="role_id[]" class="checkbox-line"></label>
            <?php foreach ($role_list as $role): ?>
                <input type="checkbox" name="role_id[]" value="<?= $role['id'] ?>" <?= in_array($role['id'], isset($item['role']) ? $item['role'] : []) ? 'checked="checked"' : ''  ?> ><?= $role['name'] . (!$role['is_enabled'] ? '(未启用)' : '') ?>
            <?php endforeach; ?>
        </div>
    </div>
</div>